package cn.smbms.controller;

import javax.annotation.Resource;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.smbms.pojo.User;

@Controller
public class UserController {

	//private Logger logger = Logger.getLogger(UserController.class);
	static Logger logger = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);
	
	 
	@Resource
	private UserService userService;
	
	
	@RequestMapping(value="/login")
	public String login(){
		logger.debug("debug message"); 
			return "login";
	}
	
	@RequestMapping(value="/login.html",method=RequestMethod.POST)
	public String doLogin(User user){
		System.err.println("haha");logger.debug("debug message");
		User user2=null;
		try {
			user2 = userService.login(user.getUserCode(), "1234567");
		} catch (Exception e) {
			e.printStackTrace();
		}
		if(null!=user2){
			return "frame";
		}else{
			return "login";
		}
	}
	
	
}
